class insert():
    def __init__(self,name,data,dateItem,leixing):
        import sqlite3
        conn = sqlite3.connect('test.db')
        #print ("Opened database successfully")
        str_chaxun = "select * from COMPANY where NAME ='{0}'".format(name)
        curse = conn.execute(str_chaxun)
        str1=''
        if curse.fetchall():
            #print(row[0])
            if leixing == 'num':
                str1 = "UPDATE COMPANY set  {0}={1}  where NAME='{2}'".format(dateItem,data,name)
            else:
                str1 = "UPDATE COMPANY set  {0}='{1}'  where NAME='{2}'".format(dateItem,data,name)
        else:
            if leixing == 'num':
                str1 = "INSERT INTO COMPANY (NAME,{0}) VALUES({1},{2})".format(dateItem,name,data)
            else:
                str1 = "INSERT INTO COMPANY (NAME,'{0}') VALUES('{1}','{2}')".format(dateItem,name,data)

        #print(str1)
        conn.execute(str1)
        conn.commit()
        #print ("Total number of rows updated :", conn.total_changes)
        #print ("Operation done successfully")
        conn.close()

#ex = insert(text,self.date_str,'TIME','string')
#ex = insert(1,'kitta','NAME','string')